/**
 * 
 */
package org.vsg.stock.dzh;

import java.io.File;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.vsg.common.configration.PropertiesSupport;
import org.vsg.stock.basic.persistence.StockCategoryDao;
import org.vsg.stock.extension.service.StockMigrationService;


/**
 * @author vison
 *
 */
public class UpdateStockPerformance {

	private final static Logger logger = LoggerFactory.getLogger(UpdateStockPerformance.class);	
	
	
	public void exec(ApplicationContext appContext) throws Exception {
		
		PropertiesSupport proSupport = (PropertiesSupport)appContext.getBean("propertyConfigurer");
		
		String vsatDir = proSupport.getProperties().getProperty("stock.realvsat");
		
		StockMigrationService stkMigraService = (StockMigrationService)appContext.getBean("stockMigrationService");
		
		// --- import concept ---
		File vsatD = new File(vsatDir);
		
		stkMigraService.updateStockPerformanceFromVsatData( vsatD );





	}
	
	

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ClassLoader clsLoader = UpdateStockPerformance.class.getClassLoader();
		// --- run the main page ---
		// build the read the path , dzh's home path
		String[] configContextFiles = {
				"classpath:/spring/configurationContext.xml",
				"classpath*:/spring/applicationContext.xml",
				"classpath*:/spring/dataAccessContext.xml"
		};
		
		ApplicationContext ctx = new ClassPathXmlApplicationContext(configContextFiles,true);
		
	
		UpdateStockPerformance mainProg = new UpdateStockPerformance();
		
		try {
			mainProg.exec(ctx);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		logger.info("program run ... Ok!");
		



	}

}
